import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 所属行业下拉框 + 树 + 表格数据
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getCurriculumclassPage',
    method: 'post',
    data: data
  })
}

// 根据 课程类型 获取 课程分类 数据列表 【getCurriculumclass】
export function getClassTree(val) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    typeId: val.typeId, //课程类型 id
    typeVal: val.typeVal, // 课程类型
    topLevel: val.topLevel
  }
  return request({
    url: '/getCurriculumclass',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    typeId: queryParams.typeId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords,
    dictId: queryParams.dictId, //分类 id
  }
  return request({
    url: '/getCurriculumclassList',
    method: 'post',
    data: data
  })
}

// 新增
export function addData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      typeId: val.typeId, //课程类型 id
      typeVal: val.typeVal, //课程类型 选中的文本
      tid: val.tid, //顶级id
      dictId: val.dictId, //上级id
      titleName: val.titleName, //标题名称
      sort: val.sort //位置排序
    }
  }
  data.projectContent.ascriptionId = store.state.userInfo.ascriptionId
  return request({
    url: '/addCurriculumclass',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getCurriculumclassData',
    method: 'post',
    data: data
  })
}


// 修改
export function updateData(val) {
  const data = {
    projectContent: {
      theid: val.id, //id
      titleName: val.titleName, //标题名称
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateCurriculumclass',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delCurriculumclass',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleIndustryclass',
    method: 'post',
    data: data
  })
}